﻿
var userIdId;

//判断IOS Android设备
$(function(){
	if (isIOS()) {
		window.webkit.messageHandlers.test1.postMessage(null);
	}else{
		userIdId = JavascriptInterface.getUserId();
		content();
	}
});

//IOS回调函数
function getUserId(userId){
	userIdId = userId;
	content();
	
}

//封装数据+JS	
function content(){
	//本地模拟数据
	var data ={
		itemList:[
			{
				url:"images/smby.png",
				name:"上门保养",
				alt:"上门保养"
			},
			{
				url:"images/shopping.png",
				name:"商城",
				alt:"商城"
			},
			{
				url:"images/used-car.png",
				name:"二手车",
				alt:"二手车"
			},
			{
				url:"images/oil.png",
				name:"石墨烯机油",
				alt:"石墨烯机油"
			},
			{
				url:"images/test-diver.png",
				name:"试乘试驾",
				alt:"试乘试驾"
			},
			{
				url:"images/dd-family.png",
				name:"叮叮之家",
				alt:"叮叮之家"
			},
			{
				url:"images/dd-club.png",
				name:"叮叮俱乐部",
				alt:"叮叮俱乐部"
			},
			{
				url:"images/new-sell.png",
				name:"新车销售",
				alt:"新车销售"
			},
			
			{
				url:"images/insurance.png",
				name:"保险",
				alt:"保险"
			},
			{
				url:"images/maintain.png",
				name:"维修",
				alt:"维修"
			}
			

		]
	};

	var tpl = document.getElementById("tpl").innerHTML;
	var html =juicer(tpl,data);
	$("body").html(html);

	
	//取消上门保养遮罩层
	$(".serve-content0").find(".mask").remove();
	$(".serve-content0").find(".mask_span").remove();

	//取消商城遮罩层
	$(".serve-content1").find(".mask").remove();
	$(".serve-content1").find(".mask_span").remove();
	
	//取消二手车遮罩层
	$(".serve-content2").find(".mask").remove();
	$(".serve-content2").find(".mask_span").remove();
	
	//石墨烯基友遮罩层
	$(".serve-content3").find(".mask").remove();
	$(".serve-content3").find(".mask_span").remove();


	//上门保养页面激活,跳转
	$(".serve-content0").on("click",function(){
//		 window.location.href='http://wx.pdyulu.com/active/active.aspx?service=027b4329-7db1-4414-bd49-f0f142518df3';
		//自己的title
		var url = "http://wx.pdyulu.com/active/active.aspx?service=027b4329-7db1-4414-bd49-f0f142518df3";
		if(isIOS()) {
			var message = {url: url};
			window.webkit.messageHandlers.maintain.postMessage(message);
		}
		else {
			JavascriptInterface.openWebPageByUrl(url);
		}
	});


	//商城页面激活,跳转
	$(".serve-content1").on("click",function(){
		// window.location.href='http://pdhz-dddc.com/dingding-web/shop/shopindex.html?id=' + userIdId;
		//客户端的title(原生title)
//		var url = "http://pdhz-dddc.cn/dingding-web/shop/shopindex.html?id=" + userIdId;
		var url = "http://www.pd-qiche.com";
		if(isIOS()) {
			var message = {url: url};
			window.webkit.messageHandlers.shop.postMessage(message);
		}
		else {
			JavascriptInterface.openWebPageByUrl(url);
		}
	});
	
	//二手车页面激活，跳转
	$(".serve-content2").on("click",function(){
//		 window.location.href='http://wx.pdyulu.com/active/active.aspx?service=027b4329-7db1-4414-bd49-f0f142518df3';
		//自己的title
		var url = "http://m.pducar.com/";
		if(isIOS()) {
			var message = {url: url};
			window.webkit.messageHandlers.maintain.postMessage(message);
		}
		else {
			JavascriptInterface.openWebPageByUrl(url);
		}
	});
	

	//石墨烯基友页面激活，跳转
	$(".serve-content3").on("click",function(){

		var url = "https://shop149074127.taobao.com";
		if(isIOS()) {
			var message = {url: url};
			window.webkit.messageHandlers.maintain.postMessage(message);
		}
		else {
			JavascriptInterface.openWebPageByUrl(url);
		}
	});
	
}
